package com.yituo.mjworld.mvc.entity.web;

import com.yituo.mjworld.core.annotation.Rules;
import com.yituo.mjworld.core.web.core.BaseForm;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = "web_user_address", schema = "web_mojianworld_server", catalog = "")
public class WebUserAddress extends BaseForm{
  @Rules(id = true)
  public int id;
  @Rules(fieldName = "用户ID")
  public String userId;
  @Rules(fieldName = "省份")
  public String provice;
  @Rules(fieldName = "市")
  public String city;
  @Rules(fieldName = "区/县")
  public String area;
  @Rules(fieldName = "详细地址")
  public String address;
  @Rules(fieldName = "邮编",required = false)
  public String postcode;
  @Rules(fieldName = "联系人电话")
  public String contactTel;
  @Rules(fieldName = "接受人姓名")
  public String receiver;
  public Date createDate;
  @Rules(fieldName = "序列号")
  private Integer orderNum;
  @Rules(fieldName = "是否为默认地址",required = false)
  private boolean isDefault;

  @Id
  @Column(name = "id", nullable = false)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  @Basic
  @Column(name = "userId", nullable = false, length = 36)
  public String getUserId() {
    return userId;
  }

  public void setUserId(String userId) {
    this.userId = userId;
  }

  @Basic
  @Column(name = "provice", nullable = false, length = 11)
  public String getProvice() {
    return provice;
  }

  public void setProvice(String provice) {
    this.provice = provice;
  }

  @Basic
  @Column(name = "city", nullable = false, length = 11)
  public String getCity() {
    return city;
  }

  public void setCity(String city) {
    this.city = city;
  }

  @Basic
  @Column(name = "area", nullable = false, length = 11)
  public String getArea() {
    return area;
  }

  public void setArea(String area) {
    this.area = area;
  }

  @Basic
  @Column(name = "address", nullable = false, length = 50)
  public String getAddress() {
    return address;
  }

  public void setAddress(String address) {
    this.address = address;
  }

  @Basic
  @Column(name = "postcode", nullable = false, length = 8)
  public String getPostcode() {
    return postcode;
  }

  public void setPostcode(String postcode) {
    this.postcode = postcode;
  }

  @Basic
  @Column(name = "contactTel", nullable = false, length = 11)
  public String getContactTel() {
    return contactTel;
  }

  public void setContactTel(String contactTel) {
    this.contactTel = contactTel;
  }

  @Basic
  @Column(name = "receiver", nullable = false, length = 10)
  public String getReceiver() {
    return receiver;
  }

  public void setReceiver(String receiver) {
    this.receiver = receiver;
  }

  @Basic
  @Column(name = "createDate", nullable = false)
  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }

  @Basic
  @Column(name = "orderNum", nullable = true)
  public Integer getOrderNum() {
    return orderNum;
  }

  public void setOrderNum(Integer orderNum) {
    this.orderNum = orderNum;
  }

  @Basic
  @Column(name = "isDefault", nullable = false)
  public boolean getIsDefault() {
    return isDefault;
  }

  public void setIsDefault(boolean isDefault) {
    this.isDefault = isDefault;
  }

  @Override
  public int hashCode() {
    int result = id;
    result = 31 * result + (userId != null ? userId.hashCode() : 0);
    result = 31 * result + (provice != null ? provice.hashCode() : 0);
    result = 31 * result + (city != null ? city.hashCode() : 0);
    result = 31 * result + (area != null ? area.hashCode() : 0);
    result = 31 * result + (address != null ? address.hashCode() : 0);
    result = 31 * result + (postcode != null ? postcode.hashCode() : 0);
    result = 31 * result + (contactTel != null ? contactTel.hashCode() : 0);
    result = 31 * result + (receiver != null ? receiver.hashCode() : 0);
    result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
    result = 31 * result + (orderNum != null ? orderNum.hashCode() : 0);
    return result;
  }

  @Override
  public boolean validate() {
    return defaultValidate();
  }
}
